﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL_Class;

namespace NLLSite.Administrator.UserControl
{
    public partial class ConfigSendMail : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DAL_Class.HocVien hv = new HocVien();
                DAL_Class.SmtpEmail sms = hv.GetConfigMail();

                txtMailFrom.Text = sms.MailFrom;
                txtPassword.Attributes.Add("value", sms.MailFromPassword);
                txtMailTo.Text = sms.MailTo;
                txtSmtpClient.Text = sms.SmtpClient;
                txtSmtpHost.Text = sms.SmtpHost;
                txtSmtpPort.Text = sms.SmtpPort.ToString();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            DAL_Class.SmtpEmail sms = new DAL_Class.SmtpEmail();
            sms.ID = 1;
            sms.MailFrom = txtMailFrom.Text;
            sms.MailFromPassword = txtPassword.Text;
            sms.MailTo = txtMailTo.Text;
            sms.SmtpClient = txtSmtpClient.Text;
            sms.SmtpHost = txtSmtpHost.Text;
            sms.SmtpPort = Convert.ToInt32(txtSmtpPort.Text);

            DAL_Class.HocVien hv = new HocVien();
            lblHint.Text = hv.ChangConfigMail(sms);
        }

    }
}